
var nunjucks = require('nunjucks');

module.exports = function(app) {
  app.set('view engine', 'html');
  app.use(function(req, res, next) {
    var env = nunjucks.configure('./app/views/', {
      autoescape: true,
      express: app
    });
    req.nunjucks = env;
    if (req.session.user) {
      req.nunjucks.addGlobal('sessionUser', req.session.user);
    }
    next();
  });
};
